package edu.sctu.zhoudie.mouth201506.day20150616;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * Created by user08 on 2015/6/16.
 */
public class MyURL {
    public void urlConnection(String ip) throws IOException {
        int count;
        URL url = new URL(ip);
        byte[] buffer = new byte[1024];
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        InputStream inputStream = connection.getInputStream();
    while ((count=inputStream.read(buffer))!=-1){
        System.out.println(new String(buffer,0,count,"gb2312"));
    }
    }

}
